package com.jeff.snake.activity;

import com.jeff.snake.R;
import com.jeff.snake.view.SnakeView;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;

public class SnakeActivity extends Activity implements OnClickListener {

	private SnakeView mSnakeView;
	private ImageView imgTitle;
	private ImageButton btnStart, btnUp, btnDown, btnLeft, btnRight;
	private RelativeLayout layoutControl, layoutTitle;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.welcome);

		imgTitle = (ImageView) findViewById(R.id.img_title);
		btnStart = (ImageButton) findViewById(R.id.btn_start);
		btnUp = (ImageButton) findViewById(R.id.btn_up);
		btnDown = (ImageButton) findViewById(R.id.btn_down);
		btnLeft = (ImageButton) findViewById(R.id.btn_left);
		btnRight = (ImageButton) findViewById(R.id.btn_right);

		layoutControl = (RelativeLayout) findViewById(R.id.layout_control);
		layoutTitle = (RelativeLayout) findViewById(R.id.layout_title);

		mSnakeView = (SnakeView) findViewById(R.id.snake_view);

		btnStart.setOnClickListener(this);
		btnUp.setOnClickListener(this);
		btnDown.setOnClickListener(this);
		btnLeft.setOnClickListener(this);
		btnRight.setOnClickListener(this);
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_start:
			imgTitle.setVisibility(View.GONE);
			btnStart.setVisibility(View.GONE);
			layoutControl.setVisibility(View.VISIBLE);
			layoutTitle.setVisibility(View.VISIBLE);
			mSnakeView.setVisibility(View.VISIBLE);
			mSnakeView.startGame();
			break;
		case R.id.btn_up:
			break;
		case R.id.btn_down:
			break;
		case R.id.btn_left:
			break;
		case R.id.btn_right:
			break;
		}

	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

}